import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase="DBshop006_订单管理删除查询"
# 1.点击销售管理订单管理界面。
firefox=openBrowser("http://localhost/dbshop/admin")
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"销售管理","订单管理")
# 记录订单数量
body=firefox.find_element_by_xpath("//body").text
l="订单数："
r="\)"
number1=reGetString(body,l,r)
# 2.在订单状态点击已取消一栏，点击“搜索”按钮一款，勾选之后，选择删除，点击提交操作。
firefox.find_element_by_xpath("(//option)[2]").click()
firefox.find_element_by_xpath("(//button[@class='btn btn-small btn-primary'])[1]").click()
firefox.find_element_by_xpath("(//input[@name='order_id[]'])[1]").click()
firefox.find_element_by_xpath("//select[@id='allEdit']/option[2]").click()
firefox.find_element_by_xpath("(//button[@class='btn btn-small btn-primary'])[3]").click()
time.sleep(1)
firefox.switch_to.alert.accept()
time.sleep(2)
# 3.删除成功
body=firefox.find_element_by_xpath("//body").text
number2=reGetString(body,l,r)
try:
    if int(number1)==int(number2)+1:
        writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()

